import type * as Project from './type.ts';
import { request } from '@/http/axios.ts';

/** 获取项目列表接口 */
export const getProjectListApi = async () =>
  request<Project.CurrentProjectListResponseData>({
    url: '/project/list',
    method: 'POST',
  });

/** 创建项目 */
export const addProjectApi = async (data: any) =>
  request({
    url: '/project/createProject',
    method: 'POST',
    data,
  });

/** 获取项目详情 */
export const getProjectInfoApi = async (data: any) =>
  request({
    url: '/project/info',
    method: 'POST',
    data,
  });

/** 更新项目 */
export const updateProjectInfo = async (data: any) =>
  request({
    url: '/project/updateInfo',
    method: 'POST',
    data,
  });

/** 删除项目 */
export const deleteProjectApi = async (data: any) =>
  request({
    url: '/project/deleteProject',
    method: 'POST',
    data,
  });

/** 获取项目模块树，用来渲染左侧导航栏 */
export const getModuleTree = async (data: { projectId: number }) =>
  request({
    url: '/project/moduleTree',
    method: 'POST',
    data,
  });

/** 获取接口详情 */
export const getApiDetail = async (data: { id: number }) =>
  request({
    url: '/project/getApiDetail',
    method: 'POST',
    data,
  });

/** 更新接口详情 */
export const updateApiDetail = async (data: any) =>
  request({
    url: '/project/updateApiDetail',
    method: 'POST',
    data,
  });

/** 创建接口 */
export const createApiDetail = async (data: any) =>
  request<Project.CurrentApiDetailResponseData>({
    url: '/project/createApiDeatial',
    method: 'POST',
    data,
  });

/** 删除接口 */
export const deleteApi = async (data: any) =>
  request({
    url: '/project/deleteApi',
    method: 'POST',
    data,
  });

/** 获取顶级模块列表 */
export const getTopLevelModules = async (data: any) =>
  request({
    url: '/project/getTopLevelModules',
    method: 'POST',
    data,
  });

/** 获取子模块或api列表 */
export const getModuleChildren = async (data: any) =>
  request({
    url: '/project/getModuleChildren',
    method: 'POST',
    data,
  });

/** 根据一个id找到查到该节点的最短树 */
export const getShortestTreeById = async (data: any) =>
  request({
    url: '/project/getShortestTreeById',
    method: 'POST',
    data,
  });

/** 添加模块 */
export const AddModule = async (data: any) =>
  request({
    url: '/project/AddModuleApi',
    method: 'POST',
    data,
  });

/** 编辑模块 */
export const editModule = async (data: any) =>
  request({
    url: '/project/editModuleApi',
    method: 'POST',
    data,
  });

/** 删除模块 */
export const deleteModuleApi = async (data: any) =>
  request({
    url: '/project/deleteModuleApi',
    method: 'POST',
    data,
  });

/** api搜索接口 */
export const searchProjectApis = async (data: any) =>
  request({
    url: '/project/searchApis',
    method: 'POST',
    data,
  });

/** 获取数据统计接口 */
export const getDataStatistics = async (data: any) =>
  request({
    url: '/project/getDataStatistics',
    method: 'POST',
    data,
  });
